#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef double D;
typedef long double LD;
typedef pair<ll, ll> pll;
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a, n) for (int i = a; i < (n); i++)
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
void solve(){
int n;
cin >> n;
vector<int> a(n);
bool sorted=1;
for(int i=0;i<n;i++){
cin >> a[i];
if(i>0&&a[i]<a[i-1]) sorted=0;
}
bool zero=false;
bool one=false;
for(int i=0;i<n;i++){
int x;
cin >> x;
if(x==0) zero=true;
if(x==1) one=true;
}
if(zero&&one) cout << "yes" << endl;
else if(sorted) cout << "yes" << endl;
else cout << "no" << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
1108B - Divisors of Two Integers | 1175A - From Hero to Zero |
1141A - Game 23 | 1401B - Ternary Sequence |
598A - Tricky Sum | 519A - A and B and Chess |
725B - Food on the Plane | 154B - Colliders |
127B - Canvas Frames | 107B - Basketball Team |
245A - System Administrator | 698A - Vacations |
1216B - Shooting | 368B - Sereja and Suffixes |
1665C - Tree Infection | 1665D - GCD Guess |
29A - Spit Problem | 1097B - Petr and a Combination Lock |
92A - Chips | 1665B - Array Cloning Technique |
1665A - GCD vs LCM | 118D - Caesar's Legions |
1598A - Computer Game | 1605A - AM Deviation |
1461A - String Generation | 1585B - Array Eversion |
1661C - Water the Trees | 1459A - Red-Blue Shuffle |
1661B - Getting Zero | 1661A - Array Balancing |